We introduce our newly developed two different, three dimensional magneto hydrodynamical codes in detail. One of our codes is written in the Newtonian limit (NMHD) and the other is in the fully general relativistic code (GRMHD). Both codes employ adaptive mesh refinement and, in GRMHD, the metric is evolved with the "Baumgarte-Shapiro-Shibata-Nakamura" formalism known as the most stable method at present. We did several test problems and as for the first practical test, we calculated gravitational collapse of a $15M_\odot$ star. Main features found from our calculations are; (1) High velocity bipolar outflow is driven from the proto-neutronstar and moves through along the rotational axis in strongly magnetized models; (2) A one-armed spiral structure appears which is originated from the low-$|T/W|$ instability; (3) By comparing GRMHD and NMHD models, the maximum density increases about $\sim30%$ in GRMHD models due to the stronger gravitational effect. These features agree very well with previous studies and our codes are thus reliable to numerical simulation of gravitational collapse of massive stars.